Skip to content

Auto select when only one NABSL exists#193

Merged
NicholasYancey merged 1 commit into
migtools:oadp-devfrom
NicholasYancey:auto-select-nabsl
Jun 4, 2026
Merged

Auto select when only one NABSL exists#193
NicholasYancey merged 1 commit into
migtools:oadp-devfrom
NicholasYancey:auto-select-nabsl

Conversation

@NicholasYancey
Copy link
Copy Markdown
Contributor

@NicholasYancey NicholasYancey commented May 29, 2026

Why the changes were made

  • When a user has only one NABSL in their namespace, they don't need to specify --storage-location flag since
    there is only one valid option.

How to test the changes made

  • Check only one NABSL exists: oc oadp nonadmin bsl get
  • Create a nonadmin backup without a --storage-location flag: oc oadp nonadmin backup create test-backup
  • The new changes should auto-select the storage location with the only NABSL name available.

Expected output:
Auto-selected storage location: (only NABSL in namespace)
NonAdminBackup request "test-backup" submitted successfully.

Summary by CodeRabbit

  • New Features

    • Auto-selects a non-admin backup storage location when exactly one usable location exists in the current namespace, and displays an "Auto-selected storage location" message with a warning about future placement changes.
  • Bug Fixes

    • Defers config-based storage location lookup until after the current namespace is determined for more accurate resolution.

Review Change Stack

@NicholasYancey NicholasYancey self-assigned this May 29, 2026
@NicholasYancey NicholasYancey added the enhancement new feature or improvements to existing ones label May 29, 2026
@openshift-ci openshift-ci Bot requested review from kaovilai and mpryc May 29, 2026 15:37
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3963622-9f58-45b6-bf0d-deab128c488d

📥 Commits

Reviewing files that changed from the base of the PR and between 98f3406 and 28bde6a.

📒 Files selected for processing (1)
  • cmd/non-admin/backup/create.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/non-admin/backup/create.go

📝 Walkthrough

Walkthrough

CreateOptions.Complete now defers config default lookup until after the Kubernetes client and namespace are available; if StorageLocation remains unset, it lists NonAdminBackupStorageLocation in the current namespace, filters to NonAdminPhaseCreated, and auto-selects when exactly one usable NABSL exists.

Changes

Storage Location Resolution

Layer / File(s) Summary
NABSL config lookup and auto-selection
cmd/non-admin/backup/create.go
CreateOptions adds a storageLocationAutoSelected field. Config-derived default NABSL lookup is moved to run after Kubernetes client creation and namespace determination. If StorageLocation remains unset, the command lists NonAdminBackupStorageLocation objects in the current namespace, filters to NonAdminPhaseCreated, and auto-selects StorageLocation only when exactly one usable NABSL exists; Run prints an auto-selection info/warning when applicable.

🎯 3 (Moderate) | ⏱️ ~20 minutes

A rabbit hops through configs with K8s in tow,
Finds storage by namespace where single blossoms grow,
One NABSL stands — chosen with a cheer,
A gentle warning whispered, future ones may steer,
Hoppity backup, safe and clear! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: auto-selecting a NonAdminBackupStorageLocation when only one exists in the namespace.
Description check ✅ Passed The pull request description includes all required sections: explanation of why changes were made and detailed testing instructions with expected output.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/non-admin/backup/create.go`:
- Around line 176-189: The auto-select message is printed in Complete
(fmt.Printf in the block that sets o.StorageLocation using nabslList) which
breaks -o yaml/json output; change CreateOptions to add a boolean flag (e.g.,
storageLocationAutoSelected bool) set to true inside Complete when you
auto-select o.StorageLocation from nabslList, remove the fmt.Printf from
Complete, and then in Run—after the PrintWithFormat early return and alongside
the existing storageLocationFromConfig handling—emit the user-facing message
about auto-selection if storageLocationAutoSelected is true so the message is
suppressed for formatted output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d11b8f22-d7a8-491f-934c-6bdf1df95fed

📥 Commits

Reviewing files that changed from the base of the PR and between 21c2e9c and 98f3406.

📒 Files selected for processing (1)
  • cmd/non-admin/backup/create.go

Comment thread cmd/non-admin/backup/create.go Outdated
Comment thread cmd/non-admin/backup/create.go Outdated
@NicholasYancey NicholasYancey force-pushed the auto-select-nabsl branch 2 times, most recently from 9f48cd2 to 29f1a7d Compare May 29, 2026 16:10
@kaovilai kaovilai requested a review from Copilot May 29, 2026 16:12
Copy link
Copy Markdown
Member

@kaovilai kaovilai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a warning that, if the user creates another non-admin BackupStorageLocation in the future, the backups may not go to the same location?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates non-admin backup creation so the CLI can resolve a storage location automatically when the user does not pass --storage-location.

Changes:

  • Adds tracking for auto-selected storage locations.
  • Moves default NABSL lookup after namespace/client setup.
  • Lists NABSLs in the current namespace and auto-selects when exactly one exists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/non-admin/backup/create.go Outdated
Comment thread cmd/non-admin/backup/create.go
Copy link
Copy Markdown
Member

@kaovilai kaovilai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will see if others wants this

@NicholasYancey NicholasYancey removed the request for review from mpryc June 1, 2026 15:05
Comment thread cmd/non-admin/backup/create.go Outdated
@openshift-ci openshift-ci Bot added the approved label Jun 2, 2026
@kaovilai
Copy link
Copy Markdown
Member

kaovilai commented Jun 3, 2026

@weshayutin @mpryc thoughts?

@weshayutin
Copy link
Copy Markdown
Contributor

If there is only one approved NABSL I think tthis is a great idea. Once there is more than one NABSL ( approved / not approved ) the user should be prompted to choose. I would need to get setup for a more indepth test

@kaovilai
Copy link
Copy Markdown
Member

kaovilai commented Jun 4, 2026

Once there is more than one NABSL ( approved / not approved ) the user should be prompted to choose

@coderabbitai create issue to track

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
gh issue create \
  --repo migtools/oadp-cli \
  --title "Prompt user to choose NABSL when more than one exists" \
  --body "## Summary

When a user has more than one NonAdminBackupStorageLocation (NABSL) in their namespace (approved or not approved), the CLI should prompt the user to choose which storage location to use for nonadmin backup creation, rather than failing or requiring manual flag input.

## Background

PR `#193` (https://github.com/migtools/oadp-cli/pull/193) introduced auto-selection of the storage location when exactly **one** NABSL exists in the namespace. This follow-up issue tracks the complementary behavior: interactive prompting when **multiple** NABSLs exist.

## Desired Behavior

- If exactly one NABSL exists → auto-select it (already implemented in `#193`)
- If more than one NABSL exists (regardless of approved/not approved status) → prompt the user interactively to pick one before proceeding with backup creation

## References

- PR `#193`: https://github.com/migtools/oadp-cli/pull/193
- Requested by `@kaovilai`, noted by `@weshayutin`" \
  --assignee kaovilai

Length of output: 1197



@kaovilai: Done! I've created issue #196 to track this:

Prompt user to choose NABSL when more than one exists

The issue captures the desired behavior:

  • One NABSL → auto-select (already implemented in this PR)
  • More than one NABSL (approved or not) → prompt the user to choose interactively

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 4, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Joeavaikath, kaovilai, NicholasYancey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [Joeavaikath,kaovilai]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kaovilai
Copy link
Copy Markdown
Member

kaovilai commented Jun 4, 2026

/lgtm

@kaovilai
Copy link
Copy Markdown
Member

kaovilai commented Jun 4, 2026

/cherry-pick oadp-1.6

@openshift-cherrypick-robot
Copy link
Copy Markdown

@kaovilai: once the present PR merges, I will cherry-pick it on top of oadp-1.6 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick oadp-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@NicholasYancey NicholasYancey merged commit e02116a into migtools:oadp-dev Jun 4, 2026
13 checks passed
@openshift-cherrypick-robot
Copy link
Copy Markdown

@kaovilai: new pull request created: #197

Details

In response to this:

/cherry-pick oadp-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

NicholasYancey added a commit to NicholasYancey/oadp-cli that referenced this pull request Jun 5, 2026
consistent with pr migtools#193, only uses usable nabsl

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved enhancement new feature or improvements to existing ones lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

if nonadmin: true && only 1 nabsl in namespace use that as default.

6 participants